﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DataLib.Accounts.Bus;

namespace EWMSWeb.Production
{
    public partial class OutProductList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataLib.BLL.City bllLib = new DataLib.BLL.City();

                User curUser = new User();
                curUser = (User)Session["UserInfo"];
                ListItem item = new ListItem();
                
                item.Text = "--请选择--";
                item.Value = "";
               

                // 归属地
                dropBelong.DataSource = bllLib.GetList("flag1 = '01'");
                dropBelong.DataTextField = "cityname";
                dropBelong.DataValueField = "citycode";
                dropBelong.DataBind();
                dropBelong.Items.Insert(0, item);


                item = new ListItem();
                
                item.Text = "--请选择--";
                item.Value = "";
                // 处理地
                dropGraphic.DataSource = bllLib.GetList(" flag1 ='02'");
                dropGraphic.DataTextField = "cityname";
                dropGraphic.DataValueField = "cityname";
                dropGraphic.DataBind();
                dropGraphic.Items.Insert(0, item);

                if (curUser.UserType != "AD")
                {
                    dropGraphic.ClearSelection();
                    dropGraphic.SelectedValue = curUser.CompanyCity;
                    dropGraphic.Enabled = false;
                }

                bindData();
               
            }
        }


        private void bindData()
        {
            DataTable dt = new DataTable();
            string bcity = "";
            string gcity = "";

            if (dropGraphic.SelectedItem.Text != "--请选择--")
                gcity = dropGraphic.SelectedItem.Text;
            else
                gcity = "";

            //if (dropBelong.SelectedItem.Text != "--请选择--")
            //    bcity = dropBelong.SelectedItem.Text;
            //else
            //    bcity = "";

            DataLib.BLL.OutStorage bll = new DataLib.BLL.OutStorage();
            string where = "outStorageType='31' and left(outStorageNo,1)='W'";
            


            if (bcity != "")
            {
                where += " and inDepart='" + bcity + "'";
            }

            if (gcity != "")
            {
                where += " and OutDepart='" + gcity + "'";
            }

            
            dt = bll.GetList(where).Tables[0];
            reptSCOutList.DataSource = dt;
            reptSCOutList.DataBind();
        }

        protected string GetStatus(string status)
        {
            string strstatus = "";
            switch (status)
            { 
                case "21":
                    strstatus = "待返还";
                    break;
                case "22":
                    strstatus = "待审核";
                    break;
                case "0":
                    strstatus = "已完成";
                    break;
                default:
                    strstatus = "待处理";
                    break;
            }
            return strstatus;
        }
    }
}